﻿function login() {

}

$(function () {

    var user = getCookie('user');
    var username = getCookie('username');
    var org = getCookie('org');
    if (user == undefined || user == null || user == '') {
        //alert("请重新登陆！");
    } else {
        //alert("已登陆！");
        $.toast('欢迎您，' + username);
        window.location.href = './index.html';
    }

    $('#login').click(function () {

        var u = $('#js_input_userid').val();
        var p = $('#js_input_password').val();
        if (u == undefined || u == null || u == '') {
            $.alert("没有身份证信息！", "请输入");
            return;
        }
        if (p == undefined || p == null || p == '') {
            $.alert("没有电话信息！", "请输入");
            return;
        }

        $.showLoading();
        var tm = setTimeout(function () {
            $.hideLoading();
            $.alert("系统繁忙，请稍后再试！", "超时", function () { });
        }, 20000);

        $.ajax({
            type: "GET",
            url: "http://" + B_Url + "/api/" + "baseInfo?info=login&account=" + u + '&password=' + p,
            //数据，json字符串
            //data: JSON.stringify(list),
            success: function (result) {
                $.hideLoading();
                clearTimeout(tm);
                if (result == undefined || result == null || result.Account == undefined || result.Account == null) {
                    $.alert("登陆失败！", "错误", function () {
                        return;
                    });
                } else {
                    setCookie('userid', result.UserID);
                    setCookie('user', result.Account);
                    setCookie('username', result.UserName);
                    setCookie('orgid', result.ID);
                    setCookie('org', result.YaoDianMing);
                    window.location.href = './index.html';
                }
            },
            error: function (e) { }
        });

    });


});